<script>
$(document).ready(function(){
$(".editBtn").click(function(){
	var id = $(this).attr('id').substr(5);
	var subject_sn = $("#select-subject").val();
	$.get('<?php echo $this->route("edit-group")?>',{
		subject_sn: subject_sn,
	    sn: id
		},function(data){
			$("#append-area").html(data);
            $("#append-area").slideDown();
            $("#group_name").focus();
		});
});

$(".deleteBtn").click(function(){
	 var id = $(this).attr('id').substr(7);
	     jConfirm('<?php echo $this->translate("Can you confirm delete this?")?>',
	    	     '<?php echo $this->translate("Confirmation Dialog")?>', function(r) {
		    	     if (r) {
    	    	    	$.getJSON('<?php echo $this->route("delete")?>',{
    	    	    	    sn : id
    		    	    	},function(data){
    		    	    		$("#select-subject").trigger('change');
    		    	    		jAlert('<?php echo $this->translate("deleted")?>');
    			    	  });
		    	     }
		 });
});


});
</script>

<?php if ($this->data):?>
<table class="hor-minimalist-b">
<thead>
<tr>
<th><?php echo $this->translate('group name')?></th>
<th><?php echo $this->translate('teacher')?></th>
<th><?php echo $this->translate('current number')?> / <?php echo $this->translate('member')?></th>
<th><?php echo $this->translate('action')?></th>
</tr>
</thead>
<tbody>
<?php foreach ($this->data as $row):?>
<tr>
<td><?php echo $row['group_name']?></td>
<td><?php echo $row['teacher_name']?></td>
<td><?php echo $row['cc']?> / <?php echo $row['member']?></td>
<td>
<input type="button" class="editBtn fg-button ui-state-default  ui-corner-all "
id="edit-<?php echo $row['sn']?>" value="<?php echo $this->translate('edit')?>" />
<input type="button" class="deleteBtn fg-button ui-state-default  ui-corner-all "
id="delete-<?php echo $row['sn']?>" value="<?php echo $this->translate('delete')?>" />

</td>
</tr>
<?php endforeach?>
</tbody>

</table>
<?php endif?>
